<?php
class Memo_m extends CI_Model{
	
	private $tMemos = 'memos' ;
	private $tabLog = 'sess_log';
	private $tabUsers = 'users';
	
	function Memo($id){
	$this->db->order_by('memo_id','desc');
	$param = array('user_id'=>$id);
		return	$this->db->get_where($this->tMemos,$param)->result_array();
	}
	function dispSingMemo($id){
		$param = array('memo_id'=>$id);
		return	$this->db->get_where($this->tMemos,$param)->row_array();	
	}
	function update($data,$id){
		$this->db->where('memo_id',$id);
		$this->db->update($this->tMemos,$data);
	}
	function save($data){
		$this->db->insert($this->tMemos,$data);
	}
	function del($id){
		$this->db->where('memo_id',$id);
		$this->db->delete($this->tMemos);
	}
	function dispLog($id){
	$users =$this->tabUsers;
	$sesslog = $this->tabLog;
	$this->db->select('users.user_id,users.email,users.firstname,sess_log.status');
	$this->db->from($sesslog);
	$this->db->join($users,$users.'.user_id = ' .$sesslog.'.user_id' ,'inner');
	$this->db->where($sesslog.'.status','1');
	$this->db->where($sesslog.'.user_id !=' , $id);
	return $this->db->get()->result_array();	
	}
}

?>